import { defHttp } from '/@/utils/http/axios'
import { LoginParams } from './model/userModel'

import { ErrorMessageMode } from '/#/axios'

enum Api {
  Login = '/api/website/admin/login',
  Index = '/api/website/admin/index',
  ChangePassword = '/api/website/admin/change-password',
  Online = '/api/website/admin/website/online',
  Offline = '/api/website/admin/website/offline',
  createUser = '/api/website/admin/user/create',
  Register = 'api/website/admin/account/register',
  checkNew = '/api/website/admin/check-new',
  Authorize = '/api/website/admin/rent/authorize',
  Hadpay = '/api/website/admin/rent/hadpay',
  Renewal = '/api/website/admin/rent/renewal',
  Send = '/api/website/admin/rent/send',
  Delete = '/api/website/admin/rent/delete',
  Addarticle = '/api/website/admin/article/add',
  UpdateUser= '/api/website/admin/user/update',
}

/**
 * @description: user login api
 */
export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<any>(
    {
      url: Api.Login,
      params,
    },
    {
      errorMessageMode: mode,
    },
  )
}
//后台管理首页
export function adminIndex(params: any) {
  return defHttp.get({ url: Api.Index, params })
}

//管理员修改密码
export function changeAdminPassword(params: any) {
  return defHttp.post({ url: Api.ChangePassword, params })
}
//网站上线
export function online(params: any) {
  return defHttp.get({ url: Api.Online, params })
}
//网站下线
export function offline(params: any) {
  return defHttp.get({ url: Api.Offline, params })
}
//创建用户
export function createUser(params: any) {
  return defHttp.post({ url: Api.createUser, params })
}
//用户注册
export function registerApi(params: any) {
  return defHttp.post({ url: Api.Register, params })
}
//查新
export function checkNew(params: any) {
  return defHttp.get({ url: Api.checkNew, params })
}

//授权
export function authorize(params: any) {
  return defHttp.post({ url: Api.Authorize, params })
}
//已付款
export function hadpay(params: any) {
  return defHttp.post({ url: Api.Hadpay, params })
}
//续租
export function renewal(params: any) {
  return defHttp.post({ url: Api.Renewal, params })
}
//发送
export function send(params: any) {
  return defHttp.post({ url: Api.Send, params })
}
//删除
export function deleteRows(params: any) {
  return defHttp.post({ url: Api.Delete, params })
}

//添加文章
export function addArticle(params: any) {
  return defHttp.post({ url: Api.Addarticle, params })
}
//修改用户资料
export function updateUser(params: any) {
  return defHttp.post({ url: Api.UpdateUser, params })
}
